package com.ldl.origami.origamiService;

import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.ldl.origami.dao.TutorialMapper;
import com.ldl.origami.dao.UserMapper;
import com.ldl.origami.domain.Tutorial;
import com.ldl.origami.util.InitServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 功能描述:
 * 作者: LDL
 * 创建时间: 2014/7/21 21:43
 */
@Service
public class IndexService {

    @Autowired(required = false)
    private TutorialMapper tutorialMapper;

    @Autowired(required = false)
    private UserMapper userMapper;

    /**
     * 获取通过审核的所有教程
     * @return
     */
    public List<Tutorial> getAllTutorialsWithThroughTheAudit(){

        /*TutorialExample example = new TutorialExample();
        example.createCriteria().andAuditingEqualTo("Y");
        example.setOrderByClause("CREATE_TIME DESC");
        List<Tutorial> tutorials = tutorialMapper.selectByExampleWithBLOBs(example);*/

        PageBounds pageBounds = new PageBounds(1, InitServlet.indexLimit, Order.formString(InitServlet.indexOrder));
        List<Tutorial> tutorials = tutorialMapper.selectByPage(pageBounds);
        return tutorials;

    }

}
